package com.example.demo.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Objects;

@Entity
public class Pddetails {
    private int pddetailsId;
    private BigDecimal price;
    private BigDecimal weight;
    private String unit;
    private String manufacturer;
    private String outline;
    private String description;
    private Product cp;

    @Id
    @Column(name = "pddetails_id", nullable = false)
    public int getPddetailsId() {
        return pddetailsId;
    }

    public void setPddetailsId(int pddetailsId) {
        this.pddetailsId = pddetailsId;
    }

    @Basic
    @Column(name = "price", nullable = false, precision = 2)
    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Basic
    @Column(name = "weight", nullable = true, precision = 2)
    public BigDecimal getWeight() {
        return weight;
    }

    public void setWeight(BigDecimal weight) {
        this.weight = weight;
    }

    @Basic
    @Column(name = "unit", nullable = true, length = 255)
    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    @Basic
    @Column(name = "manufacturer", nullable = true, length = 255)
    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    @Basic
    @Column(name = "outline", nullable = true, length = 255)
    public String getOutline() {
        return outline;
    }

    public void setOutline(String outline) {
        this.outline = outline;
    }

    @Basic
    @Column(name = "description", nullable = true, length = 255)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pddetails pddetails = (Pddetails) o;
        return pddetailsId == pddetails.pddetailsId &&
                Objects.equals(price, pddetails.price) &&
                Objects.equals(weight, pddetails.weight) &&
                Objects.equals(unit, pddetails.unit) &&
                Objects.equals(manufacturer, pddetails.manufacturer) &&
                Objects.equals(outline, pddetails.outline) &&
                Objects.equals(description, pddetails.description);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pddetailsId, price, weight, unit, manufacturer, outline, description);
    }

    @OneToOne(mappedBy = "cpxq")
    public Product getCp() {
        return cp;
    }

    public void setCp(Product cp) {
        this.cp = cp;
    }
}
